# -*- coding: utf-8 -*-

'''
Created on 03.06.2011

@author: Vlasov A. I. <root@proscript.ru>
'''
from django.contrib.admin import ModelAdmin

import settings

class WysiwygAdmin(ModelAdmin):
    
    class Meta:
        wysiwyg_fields = ()
    
    
    def formfield_for_dbfield(self, db_field, **kwargs):
        field = super(WysiwygAdmin, self).formfield_for_dbfield(db_field, **kwargs)
        if db_field.name in self.Meta.wysiwyg_fields:
            field.widget.attrs['class'] = 'wysiwyg ' + field.widget.attrs.get('class', '')
        return field
    
    
    class Media:
        js = (settings.STATIC_URL + 'js/jquery.min.js',
              settings.STATIC_URL + 'apps/wymeditor/jquery.wymeditor.min.js',
              settings.STATIC_URL + 'js/wymeditor.js',
        )
        
        css = { 'screen' : (settings.STATIC_URL + 'apps/wymeditor/skins/default/screen.css',)}
        